<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use DB;
use Cache;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class PcontentController extends Controller
{
    /**
     * 展示文章内容
     *
     * @return object
     */
    public function getIndex($id)
    {
       //查询数据库
        $pcontent = DB::table('pcontent')->where('id',$id)->first();
        $ptypes = DB::table('ptype')->where('id',$pcontent->pid)->first();
        $pcons = DB::table('pcontent')->where('pid',$ptypes->id)->orderBy('time', 'desc')->take(8)->get();
        //获取缓存数据
        $value = Cache::get('head');
        $v = Cache::get('pcon');
        return view('Home.pcontent.index',['type'=>$value['type'],'config'=>$value['config'],'blinks'=>$value['blinks'],'datas'=>$value['datas'],'ptype'=>$value['ptype'],'pts'=>$value['pts'],'pcontent'=>$pcontent,'ptypes'=>$ptypes,'pcons'=>$pcons,'acts'=>$v['acts']]);
    }

    /**
     * 展示地图
     *
     * @return 视图
     */
    public function getMap()
    {
       //获取缓存数据
        $value = Cache::get('head');
        
        return view('Home.pcontent.map',['type'=>$value['type'],'config'=>$value['config'],'blinks'=>$value['blinks'],'datas'=>$value['datas'],'ptype'=>$value['ptype'],'pts'=>$value['pts']]);
    }
    
}
